import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Friends from '../views/Friends.vue'
import Cart from '../views/Cart.vue'
import Search from '../views/Search.vue'

Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      component: Home
    },
    {
      path: '/friends',
      component: Friends
    },
    {
      path: '/cart',
      component: Cart
    },
    {
      path: '/search',
      component: Search
    }
  ]
})

export default router

// 1. 引入安装好的vue-router
// 2. 注册路由 Vue.use()
// 3. 实例化路由对象
// 4. 定义路由规则
// 设置 hash地址 和组件的对应关系
// 5. 挂载路由
// 6. 渲染路由
